package com.community.mapper;

import com.community.pojo.Announcement;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface AnnouncementMapper {

    @Select("select announcement_id as announcementId,title,content from announcement where announcement_id=#{announcementId}")
    Announcement findAnnouncementById(Integer announcementId);

    @Select("select announcement_id as announcementId,title,content from announcement ")
    List<Announcement> findAllAnnouncement();

    @Insert("insert into announcement(announcement_id, title, content) values (#{announcementId},#{title},#{content})")
    @Options(useGeneratedKeys = true,keyProperty = "announcementId")
    int addAnnouncement(Announcement announcement);
    @Delete("delete from announcement where announcement_id=#{announcementId}")
    int deleteAnnouncementById(Integer announcementId);

    @Update("update announcement set title=#{title},content=#{content} where announcement_id=#{announcementId}")
    int updateAnnouncement(Announcement announcement);

}
